/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pi2.osr.ejb.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.GeneratedValue;
/**
 *
 * @author admin
 */
@Entity
@Table(catalog = "", schema = "P09713_2_10")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Detallecompra.findAll", query = "SELECT d FROM Detallecompra d"),
    @NamedQuery(name = "Detallecompra.findByIddetalle", query = "SELECT d FROM Detallecompra d WHERE d.iddetalle = :iddetalle"),
    @NamedQuery(name = "Detallecompra.findByCantidad", query = "SELECT d FROM Detallecompra d WHERE d.cantidad = :cantidad"),
    @NamedQuery(name = "Detallecompra.findByCalificacion", query = "SELECT d FROM Detallecompra d WHERE d.calificacion = :calificacion"),
    @NamedQuery(name = "Detallecompra.findByPrecioventa", query = "SELECT d FROM Detallecompra d WHERE d.precioventa = :precioventa")})
public class Detallecompra implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @SequenceGenerator(name="DETALLECOMPRA_IDDETALLE_GENERATOR", sequenceName="DETALLECOMPRA_SEQ", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="DETALLECOMPRA_IDDETALLE_GENERATOR")
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false, precision = 0, scale = -127)
    private BigDecimal iddetalle;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private BigInteger cantidad;
    private BigInteger calificacion;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private BigDecimal precioventa;
    @JoinColumn(name = "IDPROMOCION", referencedColumnName = "IDPROMOCION")
    @ManyToOne(fetch = FetchType.LAZY)
    private Promocion idpromocion;
    @JoinColumn(name = "IDPRODUCTO", referencedColumnName = "IDPRODUCTO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Producto idproducto;
    @JoinColumn(name = "IDCOMPRA", referencedColumnName = "IDCOMPRA", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Compra idcompra;

    public Detallecompra() {
    }

    public Detallecompra(BigDecimal iddetalle) {
        this.iddetalle = iddetalle;
    }

    public Detallecompra(BigDecimal iddetalle, BigInteger cantidad, BigDecimal precioventa) {
        this.iddetalle = iddetalle;
        this.cantidad = cantidad;
        this.precioventa = precioventa;
    }

    public BigDecimal getIddetalle() {
        return iddetalle;
    }

    public void setIddetalle(BigDecimal iddetalle) {
        this.iddetalle = iddetalle;
    }

    public BigInteger getCantidad() {
        return cantidad;
    }

    public void setCantidad(BigInteger cantidad) {
        this.cantidad = cantidad;
    }

    public BigInteger getCalificacion() {
        return calificacion;
    }

    public void setCalificacion(BigInteger calificacion) {
        this.calificacion = calificacion;
    }

    public BigDecimal getPrecioventa() {
        return precioventa;
    }

    public void setPrecioventa(BigDecimal precioventa) {
        this.precioventa = precioventa;
    }

    public Promocion getIdpromocion() {
        return idpromocion;
    }

    public void setIdpromocion(Promocion idpromocion) {
        this.idpromocion = idpromocion;
    }

    public Producto getIdproducto() {
        return idproducto;
    }

    public void setIdproducto(Producto idproducto) {
        this.idproducto = idproducto;
    }

    public Compra getIdcompra() {
        return idcompra;
    }

    public void setIdcompra(Compra idcompra) {
        this.idcompra = idcompra;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddetalle != null ? iddetalle.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Detallecompra)) {
            return false;
        }
        Detallecompra other = (Detallecompra) object;
        if ((this.iddetalle == null && other.iddetalle != null) || (this.iddetalle != null && !this.iddetalle.equals(other.iddetalle))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.pi2.osr.ejb.entites.Detallecompra[ iddetalle=" + iddetalle + " ]";
    }
    
}
